#include "installapkthread.h"

InstallAPKThread::InstallAPKThread()
{

}

void InstallAPKThread::run()
{
    process = new QProcess;
    qDebug() << filePath;
    qDebug() << "Thread Start";
    // 安装apk
    process->start("adb", QStringList() << "install" << filePath);
    if(process->waitForFinished())
    {
        QString installMessage =
                QString::fromLocal8Bit(process->readAllStandardOutput());
        installMessage = installMessage.split("\n")[0].trimmed();
        emit sendInstallMessageToMain(installMessage); // 将完成信息发送给主线程

    }
    qDebug() << "Thread Finish";

}

void InstallAPKThread::receiveFilePathFromMain(QString filePath)
{
    // 接受主线程专递过来的apk路径
    this->filePath = filePath;
}
